package com.evenmo.test;

import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import com.evenmo.mapper.CardMapper;
import com.evenmo.mapper.PersonMapper;
import com.evenmo.pojo.Card;
import com.evenmo.pojo.Person;
import com.evenmo.util.MySqlSessionFactory;

public class MybatisTest1 {

	private SqlSession session;

	private CardMapper cardDao;
	private PersonMapper personDao;
	private Card card;
	private Person person;
	@Before
	public void initDatas() {
		session = getSqlSession();
		cardDao=session.getMapper(CardMapper.class);
		personDao = session.getMapper(PersonMapper.class);
	}

	@After
	public void afterThings() {
		session.commit();
		card=new Card();
		person=new Person();
		session.close();
	}

	@Test
	public void queryCardById() {
		Card cardById = cardDao.queryCardById(1);
		System.out.println(cardById);
	}

	@Test
	public void queryPersonByPersonId() {
		Person personByPersonId = personDao.queryPersonByPersonId(1);
		System.out.println(personByPersonId);
	}

	public static SqlSession getSqlSession() {
		return MySqlSessionFactory.getSqlSession();
	}

}
